<?php

namespace Addons\OaSystem\Controller;
use Addons\OaSystem\Controller\OaDutyBaseController;

class OaNodeController extends OaDutyBaseController
{
    var $model;

    function _initialize()
    {
        $this->model = $this->getModel('oa_node');
        parent::_initialize();

    }
    function lists(){
        $list_data = $this->_get_model_list( $this->model );
        $this -> assign($list_data);
        $this->display();
    }

    function add(){
        if(IS_POST) {
            $data['appid'] = $this->appId;
            $data['name'] = $_POST['name'];
            $data['url'] = $_POST['url'];
            $data['remark'] = $_POST['remark'];
            $data['pid'] = $_POST['pid'];
            $data['process_id'] = $_POST['process_id'];
            $data['process_seq'] = $_POST['process_seq'];
            $data['scope'] = $_POST['scope'];
            $data['money_line'] = $_POST['money_line'];
            $data['failback'] = $_POST['failback'];
            $data['app_url'] = $_POST['app_url'];

            if(db_find('oa_node', ['name'=>$data['name']])) {
                $this->error('该功能名称已经存在, 请重新输入！');
                return false;
            }

            M('oa_node')->add($data);

            $this->success ( '创建' . $model ['title'] . '成功！', U ( 'lists?model=' . $model ['name'], $this->get_param ));
        } else {
            $this->display('add');
        }
    }
}